# Maintainer: David Runge <dvzrv@archlinux.org>

_name=natsort
pkgname=python-natsort
pkgver=8.4.0
pkgrel=1
pkgdesc="Simple yet flexible natural sorting in Python"
arch=(any)
url="https://github.com/SethMMorton/natsort"
license=(MIT)
depends=(
  python
  python-typing-extensions
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  python-hypothesis
  python-pytest-mock
)
optdepends=(
  'python-fastnumbers: more efficient sorting'
  'python-pyicu: sort in locale dependant manner'
)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('a005abc0fe7ccbb58d1926698a841d90f7f3eac72f062044a6716f0676e0b0766f3e7e14867fb2a0ff1124deaf9796d096744d68b2f6eea001841abed49345c8')
b2sums=('924058bd0770866d7945edc7886c5d517bf6c886b85c09f7fb0c3f4e7e7e3678993b62bf905245569e36a4acc6437f80e8671f928837d5708d1fe318c7b83320')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 {CHANGELOG.md,README.rst} -t "$pkgdir/usr/share/doc/$pkgname/"
}
